//滚动定位
function fun_scroll(){
	
	var html_height = jQ("html").height();	
	jQ("div.invite_page").css({"min-height":html_height-200});
	jQ("div.me_box").css({"max-height":html_height-260});
	jQ("div.view_con").css({"max-height":html_height-225});
}	
jQ(document).ready(function(){
	initTimeSelect();
	fun_scroll();
	
	//视图详情
	jQ("div.td_box").hide();	
	jQ("div.td_box").mouseover(function(){
		jQ(this).show();
	});
	jQ("div.td_box").mouseout(function(){
		if(jQ("#ui-datepicker-div").css("display")=="none"||typeof(jQ("#ui-datepicker-div").css("display"))=="undefined"){
			var flag=eval(jQ("div.td_box").data("flag"));
			if(flag){
				return;
			}else{
				jQ(this).hide();
			}
		}
	});
	
	//左边栏特效
	jQ("td.my_open div.my_fun a").click(function(){
		//考虑收起状态
		if(jQ("#my_open_opt a").hasClass("oc_open")){
			jQ("div.my_fun a.onit").removeClass("onit");
			jQ(this).addClass("onit");
			jQ("#my_open_opt").click();
		}else{
			if(jQ(this).hasClass("onit")){
				return;
			}else{
				var id1=jQ("div.my_fun a.onit").attr("effectzone");
				jQ("div.my_fun a.onit").removeClass("onit");
				jQ(this).addClass("onit");
				var id2=jQ(this).attr("effectzone");
				jQ("#"+id1).hide();
				jQ("#"+id2).show();
			}
		}
		
	});
	jQ("#my_open_opt").click(function(){
		//收起 padding:"3px 10px" ,
	    //padding:"5px 20px"
		if(jQ(this).find("a").hasClass("oc_close")){
			var effectzone=jQ("div.my_fun a.onit").attr("effectzone");
			if(typeof(effectzone)=='undefined')
				effectzone='my_event_today';
			jQ(this).data("onit",effectzone);
			jQ("div.my_fun a").removeClass("onit");
			jQ(this).nextAll("div.me_box").hide();
			jQ(this).next().find("a").animate({ 
			    width: "34px",
			    height:"28px"
			  }, 1000 );
			jQ("#my_event_zone").animate({ 
			    width: "36px"
			  }, 1000 );
			jQ(this).animate({ 
			    width: "36px"
			  }, 1000 );
			jQ(this).find("a").removeClass("oc_close").addClass("oc_open");
		}else if(jQ(this).find("a").hasClass("oc_open")){
			var effectzone=jQ(this).data("onit");
			if(typeof(effectzone)=='undefined')
				effectzone='my_event_today';
			jQ("#my_event_zone").animate({ 
				width: "260px"
			}, 800 );
			jQ(this).animate({ 
			    width: "259px"
			  }, 800 );
			jQ(this).next().find("a").animate({ 
			    width: "128px",
			    height:"19px"
			  }, 1200 );
			jQ(this).find("a").removeClass("oc_open").addClass("oc_close");
			jQ("div.my_fun a[effectzone='"+effectzone+"']").addClass("onit");
			jQ("#"+effectzone).show();
		}
	});
	
	jQ("#vt_oc_optzone a").click(function(){
		view_fun(jQ(this));
	});
	
	jQ("#viewopt").dialog({
		modal: true,
		bgiframe: true,
		autoOpen: false,
		closeOnEscape:false,
		draggable:false,
		height:200,
		buttons: {
			
			"确定": function() {
				var opt=jQ("#viewopt");
				var triggerfun=opt.data("function");
				opt.trigger(triggerfun);
				opt.removeData("function");
				jQ("#viewopt_p").hide();
				jQ("#viewopt_img").show();
				//activeBtnOnDialog("viewopt",false);
				//jQ(this).dialog('close');
			},
			"取消": function() {
				var viewopt=jQ("#viewopt");
				var triggerfun=jQ("#viewopt").data("function");
				viewopt.unbind(triggerfun);
				viewopt.find("input.eventid").val("");
				viewopt.removeData("function");
				jQ(this).dialog('close');
			}
		},
		close: function() {
			jQ("#viewopt_p").show();
			jQ("#viewopt_img").hide();
		},
		open:function(){
		}
	});
	
	//标记为重要
	jQ("#td_box_isvip").click(function(){
		var eventid=jQ("#td_box_eventid").val();
		if(jQ(this).hasClass("c_import")){
			jQ("#clipevent-"+eventid).find("input.isvip").val(0);
			jQ(this).attr("title","标记为不重要");
			setImport(false,eventid);
		}else{
			jQ("#clipevent-"+eventid).find("input.isvip").val(1);
			jQ(this).attr("title","标记为重要");
			setImport(true,eventid);
		}
		serializeClipEventCenterToLeft(eventid);
		jQ(this).toggleClass("c_import");
	});
	
	
	getWeekEventsByToday();
	getEventsByTodayAndTommorrow();
	getEventsByInviting();
})
/**
 * * timeattr 1:最近24个邀请档期
	 * 			2:最急的24小时内的档期
 * */
function getEventsByInviting(){
	jQ.ajax({
		type: "POST",
		url:"manageClipAjax!getEventsByInviting.action",
		success:function(data){
			var htmlurgent="";
			var htmllast="";
			jQ(data).find("EventForView").each(function(){
				var eventid=jQ(this).attr("id");
				var title=jQ(this).find("title").text();
				var eventtype=jQ(this).find("eventtype").text();
				var starttime=eval(jQ(this).find("starttime").text());
				var endtime=eval(jQ(this).find("endtime").text());
				var address=jQ(this).find("address").text();
				var clocktime=eval(jQ(this).find("clocktime").text());
				var deadlinetime=eval(jQ(this).find("deadlinetime").text());
				var isvip=eval(jQ(this).find("isvip").text());
				var timeattr=eval(jQ(this).attr("timeattr"));
				var processstatus=eval(jQ(this).find("processstatus").text());
				var reliedclip=eval(jQ(this).find("reliedclip").text());
				var publishname=jQ(this).find("publishname").text();
				var tmp="";
				tmp+="<div class='me_list clipevent-"+eventid+"'>";
				tmp+="<input type='hidden' class='eventid' value='"+eventid+"'>";
				tmp+="<input type='hidden' class='clocktime' value='"+clocktime+"'>";
				tmp+="<input type='hidden' class='isvip' value='"+isvip+"'>";
				tmp+="<div class='me_item isvip'>";
				tmp+="<span class='e_"+eventtype+"' title='"+getTypeName(eventtype)+"'></span>";
				tmp+="<span class=title'>"+htmlData(title)+"</span>";
				if(isvip)
					tmp+="<span class='c_import isvip' title='标记为不重要'></span>";
				else
					tmp+="<span class='import isvip' title='标记为重要'></span>";
				tmp+="</div><div class='me_item'>";
				tmp+="<span>发起人：</span><span>"+publishname+"</span>";
				tmp+="</div><div class='me_item'>";
				tmp+="<span class='time'><b>"+formateDetailTime(starttime)+"</b><i>-</i><b>"+formateDetailTime(endtime)+"</b></span>";
				tmp+="</div><div class='me_item'>";
				tmp+="<span>截止：</span><span>";
				if(deadlinetime>0)
					tmp+=formateDetailTime(deadlinetime);
				else
					tmp+="<i>暂无</i>";
				tmp+="</span>";
				if(processstatus==0){
					tmp+="<b class='edt_ing'>进行中</b>";
				}else if(processstatus==1){
					tmp+="<b class=\"edt_over\">已结束</b>";
				}else if(processstatus==2){
					tmp+="<b class=\"edt_stop\">已停止</b>";
				}
				tmp+="</div><div class='me_item'>";
				tmp+="<span>地址：</span><span class='adr'>"+htmlData(address)+"</span>";
				tmp+="</div><div class='me_item me_clock show_clock'>";
				tmp+="<span>提醒：</span>";
				if(clocktime>0){
					tmp+="<span class='alarm clockval'>"+formateDetailTime(clocktime);
				}else{
					tmp+="<span class='clockval'><i>暂无</i>";
				}
				tmp+="</span>";
				tmp+="</div><div class='me_item me_clock set_clock' style='display:none;'>";
				tmp+="<input type='checkbox' style='margin:1px;'><span style='margin:0 5px;'>提醒</span>";
				tmp+="<input style='margin:0 5px;width:130px;' type='text' size='15' class='data'>";
				tmp+="<select class='alert_hour time_hour' style='float: left;margin-left:53px;margin-top:5px;'></select><span style='width: auto;margin-top:5px;'>时</span>";
				tmp+="<select class='alert_min time_min' style='float: left;margin-top:5px;'></select><span style='width: auto;margin-top:5px;'>分</span>";
				
				tmp+="<button style='margin-top:5px;'>确定</button></div><div class='me_item set_clock_info' style='color:#ff0000;'></div><div class='me_item opt_item'>";
				tmp+="<a class='f_info' title='档期详情'></a>";
				tmp+="<a class='f_refuse' title='拒绝邀请'></a>";
				tmp+="<a class='f_ignore' title='忽略邀请'></a>";
				tmp+="<a class='f_accept' title='接受邀请'></a>";
				if(clocktime>0){
					tmp+="<a class='alarmicon f_c_alarm' title='取消提醒' ></a>";
				}else{
					tmp+="<a class='alarmicon f_alarm' title='设置提醒' ></a>";
				}
				tmp+="</div></div>";
				
				if(timeattr==1){
					htmllast+=tmp;
				}else if(timeattr==2){
					htmlurgent+=tmp;
				}
			});
			jQ("#last_clip_zone").empty().append(htmllast);
			jQ("#urgent_clip_zone").empty().append(htmlurgent);
			noeventInvitedClips();
			jQ("#urgent_clip_zone").hide();
			{
				jQ("#invite_clip_zone div div.me_list div.set_clock select.time_hour").empty();
				var html="";
				for(var i=0;i<24;i++){
					if(i==0)
						html+="<option value="+i+">0"+i+"</option>";
					else if(i<10)
						html+="<option value="+i+">0"+i+"</option>";
					else
						html+="<option value="+i+">"+i+"</option>";
				}
				jQ("#invite_clip_zone div div.me_list div.set_clock select.time_hour").append(html);
				html="";
				jQ("#invite_clip_zone div div.me_list div.set_clock select.time_min").empty();
				for(var i=0;i<12;i++){
					var j=i*5;
					if(j==0)
						html+="<option value="+j+">0"+j+"</option>";
					else if(j<10)
						html+="<option value="+j+">0"+j+"</option>";
					else
						html+="<option value="+j+">"+j+"</option>";
				}
				jQ("#invite_clip_zone div div.me_list div.set_clock select.time_min").append(html);
				
			}
			jQ("#invite_clip_zone div div.isvip span.isvip").click(function(event){
				var curObj=jQ(event.currentTarget);
				var eventid=eval(curObj.parent().prevAll("input.eventid").val());
				var ss=jQ("div.clipevent-"+eventid+" div.isvip span.isvip");
				if(curObj.hasClass("c_import")){
					
					ss.removeClass("c_import").addClass("import");
					ss.attr("title","标记为重要");
					jQ("div.clipevent-"+eventid+" input.isvip").val(0);
					setImport(false,eventid);
				}else if(curObj.hasClass("import")){
					
					ss.removeClass("import").addClass("c_import");
					ss.attr("title","标记为不重要");
					jQ("div.clipevent-"+eventid+" input.isvip").val(1);
					setImport(true,eventid);
				}
			});
			jQ("#invite_clip_zone div div.me_item a.f_info").click(function(){
				var eventid=eval(jQ(this).parent().prevAll("input.eventid").val());
				window.location.href=jQ("#ctxVal").val()+"/myclip/clip_detail.html?eventid="+eventid;
			});
			jQ("#invite_clip_zone div div.me_item a.f_refuse").unbind("click").bind("click",refuseInvitedClip);
			jQ("#invite_clip_zone div div.me_item a.f_accept").unbind("click").bind("click",acceptInvitedClip);
				
			jQ("#invite_clip_zone div div.me_item a.f_ignore").unbind("click").bind("click",ignoreInvitedClip);
			
			jQ("#invite_clip_zone div div.me_item a.alarmicon").unbind("click").bind("click",controlClockAtRight);
//			jQ("#invite_clip_zone div div.me_item a.f_alarm").unbind("click").bind("click",addClockAtLeft);
			//jQ("#invite_clip_zone div div.me_item span.isvip").unbind("click").bind("click",setImportAtLeft);
		}
	});
}

function controlClockAtRight(event){
	var curObj=jQ(event.currentTarget);
	if(curObj.hasClass("f_alarm")){
		//addClock
		var eventid=curObj.parent().prevAll("input.eventid").val();
		var showclock=curObj.parent().prevAll("div.show_clock");
		var setclock=curObj.parent().prevAll("div.set_clock");
//		var iconObj=jQ(event.currentTarget);
		if(showclock.css("display")=="none"){
			setclock.hide();
			showclock.show();
			return;
		}
		showclock.hide();
		setclock.show();
		setclock.find("input:checkbox").attr("checked","true");
		setclock.find("input:text").val("").datepicker( "destroy" );
		setclock.find("select.alert_hour").val(0);
		setclock.find("select.alert_min").val(0);
		setclock.find("input:text").datepicker({dateFormat: 'yy-mm-dd',  
			beforeShow: function(i,e){  
			var z = jQuery(i).closest(".ui-dialog").css("z-index") + 4;  
			e.dpDiv.css('z-index', z);  
		}});
		
		
		setclock.find("button").unbind("click").bind("click",function(){
			
			var isChecked=eval(jQ(this).prevAll("input:checkbox").attr("checked"));
			var errzone=jQ(this).parent().nextAll("div.set_clock_info");
			if(isChecked){
				var alertdateval=jQ(this).prevAll("input:text").val();
				if(alertdateval==null||alertdateval.length<=0){
					errzone.empty();
					errzone.append("请选择提醒的时间。");
					errzone.show();
					return;
				}else{
					errzone.empty();
				}
				
				var alertdate=jQ(this).prevAll("input:text").datepicker( "getDate" );
				var alerthour=eval(jQ(this).prevAll("select.alert_hour").val());
				var alertmin=eval(jQ(this).prevAll("select.alert_min").val());
				alertdate.setHours(alerthour);
				alertdate.setMinutes(alertmin);
				var alertlong=alertdate.getTime();
				var nowdate=new Date();
				if(alertlong<nowdate){
					errzone.empty();
					errzone.append("提醒的时间应该是将来的时间。");
					errzone.show();
					return;
				}else{
					errzone.empty();
				}
				var btnObj=jQ(this);
				jQ.ajax({
					type: "POST",
					url:"eventAjax!addEventClock.action",
					data:{
						eventid:eventid,
						alerttime:alertlong
					},
				success:function(data){
					if(data!=null){
						var dataObj=eval("("+data+")");//转换为json对象
						if(dataObj['result']){
							
							setclock.hide();
							showclock.show();
							btnObj.unbind("click");
							jQ("div.clipevent-"+eventid+" input.clocktime").val(alertlong);
							var ss=jQ("div.clipevent-"+eventid+" div.show_clock span.clockval");
							ss.addClass("f_alarm").empty().append(formateDetailTime(alertlong));
							var ss2=jQ("div.clipevent-"+eventid+" div.opt_item a.alarmicon");
							ss2.removeClass("f_alarm").addClass("f_c_alarm").attr("title","取消提醒");
							ss2.unbind("click").bind("click",cancelClockAtLeft);
							serializeClipEventLeftToCenter(eventid)
						}else{
						}
					}
				}
				});
			}else{
				errzone.empty().append("请打钩“设置提醒”选项");
				return;
			}
		});
	}else if(curObj.hasClass("f_c_alarm")){
		//cancelClock
		var eventid=jQ(event.currentTarget).parent().prevAll("input.eventid").val();
		var setclock=jQ(event.currentTarget).parent().prevAll("div.set_clock");
		var showclock=jQ(event.currentTarget).parent().prevAll("div.show_clock");
		var iconObj=jQ(event.currentTarget);
		jQ.ajax({
			type: "POST",
			url:"eventAjax!cancelClock.action",
			data:{
				eventid:eventid
			},
			success:function(data){
				if(data!=null){
					var dataObj=eval("("+data+")");//转换为json对象
					if(dataObj['result']){
						setclock.hide();
						showclock.show();
						jQ("div.clipevent-"+eventid+" input.clocktime").val(0);
						var ss=jQ("div.clipevent-"+eventid+" div.show_clock span.clockval");
						ss.removeClass("f_alarm").empty().append("<i>暂无</i>");
						var ss2=jQ("div.clipevent-"+eventid+" div.opt_item a.alarmicon");
						ss2.removeClass("f_c_alarm").addClass("f_alarm").attr("title","设置提醒");
						ss2.unbind("click").bind("click",addClockAtLeft);
						serializeClipEventLeftToCenter(eventid);
					}else{
						
					}
				}
			}
		});
	}
}


function refuseInvitedClip(event){
	var curObj=jQ(event.currentTarget);
	var eventid=eval(curObj.parent().prevAll("input.eventid").val());
	jQ.ajax({
		type: "POST",
		url:"manageClipAjax!refuseInvitedClip.action",
		data:{
			eventid:eventid
		},
		success:function(data){
			jQ("div.clipevent-"+eventid).remove();
			noeventInvitedClips();
		}
	});
}

function ignoreInvitedClip(event){
	var curObj=jQ(event.currentTarget);
	var eventid=eval(curObj.parent().prevAll("input.eventid").val());
	jQ.ajax({
		type: "POST",
		url:"manageClipAjax!ignoreInvitedClip.action",
		data:{
			eventid:eventid
		},
		success:function(data){
			jQ("div.clipevent-"+eventid).remove();
			noeventInvitedClips();
		}
	});
}

function acceptInvitedClip(event){
	var curObj=jQ(event.currentTarget);
	var eventid=eval(curObj.parent().prevAll("input.eventid").val());
	var year=eval(jQ("#mouth_fun_weekview_year").val());
	var week=eval(jQ("#mouth_fun_weekview_week").val());
	jQ.ajax({
		type: "POST",
		url:"weekAjax!acceptInvitedClip.action",
		data:{
			eventid:eventid,
			year:year,
			numweek:week
		},
		success:function(data){
			if(data!=null){
				var obj_box = jQ(event.currentTarget);
				var obj_offset = obj_box.offset();
				var msg_box = jQ("#accept_msg_box");
				var _top = obj_offset.top - msg_box.outerHeight() - 10;
				var _left = obj_offset.left - msg_box.outerHeight()/2;
				msg_box.css({"top":_top+"px","left":_left+"px"}).show();
				msg_box.find("div.msg_note").animate({top: 20+'px'}, 500,function(){
					setTimeout(function(){
						msg_box.find("div.msg_note").animate({top: 100+'px'},500);
					},2000);
				});
				var jsonobj=eval("("+data+")");
				var eventid=jsonobj.eventid;
				jQ("div.clipevent-"+eventid).remove();
				noeventInvitedClips();
				var title=jsonobj.title;
				var eventtype=jsonobj.eventtype;
				var starttime=eval(jsonobj.starttime);
				var endtime=eval(jsonobj.endtime);
				var address=jsonobj.address;
				var content=jsonobj.content;
				var clocktime=eval(jsonobj.clocktime);
				var deadlinetime=eval(jsonobj.deadlinetime);
				var isvip=eval(jsonobj.isvip);
				var dayattr=eval(jsonobj.dayattr);
				var processstatus=eval(jsonobj.processstatus);
				var reliedclip=eval(jsonobj.reliedclip);
				var publishname=jsonobj.publishname;
				var iscrtweek=eval(jsonobj.iscrtweek);
				var istoday=eval(jsonobj.istoday);
				var istommorrow=eval(jsonobj.istommorrow);
				if(iscrtweek){
					var startday=eval(jsonobj.startday);
					var endday=eval(jsonobj.endday);
					var htmljoin="";
					htmljoin+="<tr >";
//					htmljoin+="<input type='hidden' value='"+iscrtweek+"' class='iscrtweek'/>";
//					htmljoin+="<input type='hidden' value='"+istoday+"' class='istoday'/>";
//					htmljoin+="<input type='hidden' value='"+istommorrow+"' class='istommorrow'/>";
					for(var i=1;i<startday;i++){
						htmljoin+="<td class='invite_event noevent' day="+i+" title='双击立即添加档期'><div class='noevent'></div></td>";
					}
					htmljoin+="<td id='clipevent-"+eventid+"' class='invite_event my_join hasevent' day="+startday+" colspan='"+(endday-startday+1)+"'>";
					htmljoin+="<div class='hasevent'>";
					htmljoin+="<input type='hidden' value='"+eventid+"' class='eventid'/>";
					htmljoin+="<input type='hidden' value='"+title+"' class='title'/>";
					htmljoin+="<input type='hidden' value='"+eventtype+"' class='eventtype'/>";
					htmljoin+="<input type='hidden' value='"+starttime+"' class='starttime'/>";
					htmljoin+="<input type='hidden' value='"+endtime+"' class='endtime'/>";
					htmljoin+="<input type='hidden' value='"+address+"' class='address'/>";
					htmljoin+="<input type='hidden' value='"+content+"' class='content'/>";
					htmljoin+="<input type='hidden' value='"+clocktime+"' class='clocktime'/>";
					htmljoin+="<input type='hidden' value='"+deadlinetime+"' class='deadlinetime'/>";
					htmljoin+="<input type='hidden' value='"+isvip+"' class='isvip'/>";
					htmljoin+="<input type='hidden' value='"+processstatus+"' class='processstatus'/>";
					htmljoin+="<input type='hidden' value='"+reliedclip+"' class='reliedclip'/>";
					htmljoin+="<input type='hidden' value='"+publishname+"' class='publishname'/>";
					htmljoin+="<a class='other'>"+htmlData(title)+"</a></div></td>";
					for(var i=0;i<7-endday;i++){
						htmljoin+="<td class='invite_event noevent' day="+(endday+1+i)+" title='双击立即添加档期'><div class='noevent'></div></td>";
					}
					htmljoin+="</tr>";
					jQ("#joinclip").append(htmljoin);
//					}
					jQ("tr.noevent").remove();
					effectEventDetail();
				}
				if(istoday||istommorrow){
					var tmp="";
					tmp+="<div class='me_list clipevent-"+eventid+"'>";
					tmp+="<input type='hidden' class='eventid' value='"+eventid+"'>";
					tmp+="<input type='hidden' class='clocktime' value='"+clocktime+"'>";
					tmp+="<input type='hidden' class='isvip' value='"+isvip+"'>";
					tmp+="<div class='me_item isvip'><span class='e_"+eventtype+"' title='"+getTypeName(eventtype)+"'></span>";
					tmp+="<span class='title'>"+htmlData(title)+"</span>";
					if(isvip)
						tmp+="<span class='c_import isvip' title='标记为不重要'></span>";
					else
						tmp+="<span class='import isvip' title='标记为重要'></span>";
					tmp+="</div><div class='me_item'>";
					tmp+="<span>发起人：</span><span>"+publishname+"</span>";
					tmp+="</div><div class='me_item'><span class='time'>";
					tmp+="<b>"+formateDetailTime(starttime)+"</b><i>-</i><b>"+formateDetailTime(endtime)+"</b>";
					tmp+="</span></div><div class='me_item'><span>截止：</span><span>";
					if(deadlinetime>0)
						tmp+=formateDetailTime(deadlinetime);
					else
						tmp+="<i>暂无</i>";
					tmp+="</span>";
					if(processstatus==0){
						tmp+="<b class='edt_ing'>进行中</b>";
					}else if(processstatus==1){
						tmp+="<b class=\"edt_over\">已结束</b>";
					}else if(processstatus==2){
						tmp+="<b class=\"edt_stop\">已停止</b>";
					}
					tmp+="</div><div class='me_item'><span>地址：</span><span class='adr'>";
					tmp+=htmlData(address);
					tmp+="</span></div><div class='me_item me_clock show_clock'><span>提醒：</span>";
					if(clocktime>0){
						tmp+="<span class='alarm clockval'>"+formateDetailTime(clocktime);
					}else{
						tmp+="<span class='clockval'><i>暂无</i>";
					}
					tmp+="</span></div><div class='me_item me_clock set_clock' style='display:none;'>";
					tmp+="<input type='checkbox' style='margin:1px;'><span style='margin:0 5px;'>提醒</span>";
					tmp+="<input style='margin:0 5px;width:130px;' type='text' size='15' class='data'>";
					tmp+="<select class='alert_hour time_hour' style='float: left;margin-left:53px;margin-top:5px;'></select><span style='width: auto;margin-top:5px;'>时</span>";
					tmp+="<select class='alert_min time_min' style='float: left;margin-top:5px;'></select><span style='width: auto;margin-top:5px;'>分</span>";
					
					tmp+="<button style='margin-top:5px;'>确定</button></div><div class='me_item set_clock_info' style='color:#ff0000;'></div><div class='me_item opt_item'>";
					if(reliedclip>0){
						tmp+="<a class='delicon f_leave' title='退出档期'></a>";
					}else{
						tmp+="<a class='delicon f_del' title='取消档期'></a>";
					}
					
					tmp+="<a class='f_info' title='详情'></a>";
					if(clocktime>0){
						tmp+="<a class='alarmicon f_c_alarm' title='取消提醒' ></a>";
					}else{
						tmp+="<a class='alarmicon f_alarm' title='设置提醒' ></a>";
					}
					tmp+="</div></div>";
					
					if(istoday){
						if(jQ("#my_event_today div.noevent").length>0){
							jQ("#my_event_today").empty().append(tmp);
						}else{
							jQ("#my_event_today").append(tmp);
						}
					}
					if(istommorrow){
						if(jQ("#my_event_tommorrow div.noevent").length>0){
							jQ("#my_event_tommorrow").empty().append(tmp);
						}else{
							jQ("#my_event_tommorrow").append(tmp);
						}
					}
					
					jQ("div.clipevent-"+eventid+" div.set_clock select.time_hour").empty();
					var html="";
					for(var i=0;i<24;i++){
						if(i==0)
							html+="<option value="+i+">0"+i+"</option>";
						else if(i<10)
							html+="<option value="+i+">0"+i+"</option>";
						else
							html+="<option value="+i+">"+i+"</option>";
					}
					jQ("div.clipevent-"+eventid+" div.set_clock select.time_hour").append(html);
					html="";
					jQ("div.clipevent-"+eventid+" div.set_clock select.time_min").empty();
					for(var i=0;i<12;i++){
						var j=i*5;
						if(j==0)
							html+="<option value="+j+">0"+j+"</option>";
						else if(j<10)
							html+="<option value="+j+">0"+j+"</option>";
						else
							html+="<option value="+j+">"+j+"</option>";
					}
					jQ("div.clipevent-"+eventid+" div.set_clock select.time_min").append(html);
					
					
					jQ("div.clipevent-"+eventid+" div.me_item a.delicon").click(function(){
						var info="";
						var title="";
						if(jQ(this).hasClass("f_leave")){
							info="您确定退出档期么？";
							title="退出档期";
						}else if(jQ(this).hasClass("f_del")){
							info="您确定取消档期么？";
							title="取消档期";
						}
						var eventid=jQ(this).parent().prevAll("input.eventid").val();
						jQ("#viewopt_eventid").val(eventid);
						var opt=jQ("#viewopt");
						opt.bind("deleteEvent",deleteEventAtLeft);
						opt.data("function","deleteEvent")
						jQ("#viewopt_p").empty().append(info);
						jQ("#viewopt").dialog( "option", "title", title);
						jQ("#viewopt").dialog("open");
					});
					jQ("div.clipevent-"+eventid+" div.me_item a.f_info").click(function(){
						var eventid=eval(jQ(this).parent().prevAll("input.eventid").val());
						window.location.href=jQ("#ctxVal").val()+"/myclip/clip_detail.html?eventid="+eventid;
					});
					jQ("div.clipevent-"+eventid+" div.me_item a.f_c_alarm").unbind("click").bind("click",cancelClockAtLeft);
					jQ("div.clipevent-"+eventid+" div.me_item a.f_alarm").unbind("click").bind("click",addClockAtLeft);
					jQ("div.clipevent-"+eventid+" div.me_item span.isvip").unbind("click").bind("click",setImportAtLeft);
				}
				
				
				
			}
		}
	});
}

function getEventsByTodayAndTommorrow(){
	jQ.ajax({
		type: "POST",
		url:"manageClipAjax!getEventsByTodayAndTommorrow.action",
		success:function(data){
			var htmltoday="";
			var htmltommorrow="";
			jQ(data).find("EventForView").each(function(){
				var eventid=jQ(this).attr("id");
				var title=jQ(this).find("title").text();
				var eventtype=jQ(this).find("eventtype").text();
				var starttime=eval(jQ(this).find("starttime").text());
				var endtime=eval(jQ(this).find("endtime").text());
				var address=jQ(this).find("address").text();
				var clocktime=eval(jQ(this).find("clocktime").text());
				var deadlinetime=eval(jQ(this).find("deadlinetime").text());
				var isvip=eval(jQ(this).find("isvip").text());
				var dayattr=eval(jQ(this).attr("dayattr"));
				var processstatus=eval(jQ(this).find("processstatus").text());
				var reliedclip=eval(jQ(this).find("reliedclip").text());
				var publishname=jQ(this).find("publishname").text();
				var tmp="";
				tmp+="<div class='me_list clipevent-"+eventid+"'>";
				tmp+="<input type='hidden' class='eventid' value='"+eventid+"'>";
				tmp+="<input type='hidden' class='clocktime' value='"+clocktime+"'>";
				tmp+="<input type='hidden' class='isvip' value='"+isvip+"'>";
				tmp+="<div class='me_item isvip'><span class='e_"+eventtype+"' title='"+getTypeName(eventtype)+"'></span>";
				tmp+="<span class='title'>"+htmlData(title)+"</span>";
				if(isvip)
					tmp+="<span class='c_import isvip' title='标记为不重要'></span>";
				else
					tmp+="<span class='import isvip' title='标记为重要'></span>";
				tmp+="</div><div class='me_item'>";
				tmp+="<span>发起人：</span><span>"+publishname+"</span>";
				tmp+="</div><div class='me_item'><span class='time'>";
				tmp+="<b>"+formateDetailTime(starttime)+"</b><i>-</i><b>"+formateDetailTime(endtime)+"</b>";
				tmp+="</span></div><div class='me_item'><span>截止：</span><span>";
				if(deadlinetime>0)
					tmp+=formateDetailTime(deadlinetime);
				else
					tmp+="<i>暂无</i>";
				tmp+="</span>";
				if(processstatus==0){
					tmp+="<b class='edt_ing'>进行中</b>";
				}else if(processstatus==1){
					tmp+="<b class=\"edt_over\">已结束</b>";
				}else if(processstatus==2){
					tmp+="<b class=\"edt_stop\">已停止</b>";
				}
				tmp+="</div><div class='me_item'><span>地址：</span><span class='adr'>";
				tmp+=htmlData(address);
				tmp+="</span></div><div class='me_item me_clock show_clock'><span>提醒：</span>";
				if(clocktime>0){
					tmp+="<span class='alarm clockval'>"+formateDetailTime(clocktime);
				}else{
					tmp+="<span class='clockval'><i>暂无</i>";
				}
				tmp+="</span></div><div class='me_item me_clock set_clock' style='display:none;'>";
				tmp+="<input type='checkbox' style='margin:1px;'><span style='margin:0 5px;'>提醒</span>";
				tmp+="<input style='margin:0 5px;width:130px;' type='text' size='15' class='data'>";
				tmp+="<select class='alert_hour time_hour' style='float: left;margin-left:53px;margin-top:5px;'></select><span style='width: auto;margin-top:5px;'>时</span>";
				tmp+="<select class='alert_min time_min' style='float: left;margin-top:5px;'></select><span style='width: auto;margin-top:5px;'>分</span>";
				
				tmp+="<button style='margin-top:5px;'>确定</button></div><div class='me_item set_clock_info' style='color:#ff0000;'></div><div class='me_item opt_item'>";
				if(reliedclip>0){
					tmp+="<a class='delicon f_leave' title='退出档期'></a>";
				}else{
					tmp+="<a class='delicon f_del' title='取消档期'></a>";
				}
				
				tmp+="<a class='f_info' title='详情'></a>";
				if(clocktime>0){
					tmp+="<a class='alarmicon f_c_alarm' title='取消提醒' ></a>";
				}else{
					tmp+="<a class='alarmicon f_alarm' title='设置提醒' ></a>";
				}
				tmp+="</div></div>";
				
				if(dayattr==1){
					htmltoday+=tmp;
				}else if(dayattr==2){
					htmltommorrow+=tmp;
				}
			});
			if(htmltoday.length==0){
				htmltoday="<div class='me_list noevent'><i>暂无</i></div>";
			}
			jQ("#my_event_today").empty().append(htmltoday);
			if(htmltommorrow.length==0){
				htmltommorrow="<div class='me_list noevent'><i>暂无</i></div>";
			}
			jQ("#my_event_tommorrow").empty().append(htmltommorrow);
			jQ("#my_event_tommorrow").hide();
			{
				jQ("#my_event_zone div.me_box div.set_clock select.time_hour").empty();
				var html="";
				for(var i=0;i<24;i++){
					if(i==0)
						html+="<option value="+i+">0"+i+"</option>";
					else if(i<10)
						html+="<option value="+i+">0"+i+"</option>";
					else
						html+="<option value="+i+">"+i+"</option>";
				}
				jQ("#my_event_zone div.me_box div.set_clock select.time_hour").append(html);
				html="";
				jQ("#my_event_zone div.me_box div.set_clock select.time_min").empty();
				for(var i=0;i<12;i++){
					var j=i*5;
					if(j==0)
						html+="<option value="+j+">0"+j+"</option>";
					else if(j<10)
						html+="<option value="+j+">0"+j+"</option>";
					else
						html+="<option value="+j+">"+j+"</option>";
				}
				jQ("#my_event_zone div.me_box div.set_clock select.time_min").append(html);
				
			}
			jQ("#my_event_zone div.me_box div.me_item a.delicon").click(function(){
				var info="";
				var title="";
				if(jQ(this).hasClass("f_leave")){
					info="您确定退出档期么？";
					title="退出档期";
				}else if(jQ(this).hasClass("f_del")){
					info="您确定取消档期么？";
					title="取消档期";
				}
				var eventid=jQ(this).parent().prevAll("input.eventid").val();
				jQ("#viewopt_eventid").val(eventid);
				var opt=jQ("#viewopt");
				opt.bind("deleteEvent",deleteEventAtLeft);
				opt.data("function","deleteEvent")
				jQ("#viewopt_p").empty().append(info);
				jQ("#viewopt").dialog( "option", "title", title);
				jQ("#viewopt").dialog("open");
			});
			jQ("#my_event_zone div.me_box div.me_item a.f_info").click(function(){
				var eventid=jQ(this).parent().prevAll("input.eventid").val();
				window.location.href=jQ("#ctxVal").val()+"/myclip/clip_detail.html?eventid="+eventid;
			});
			jQ("#my_event_zone div.me_box div.me_item a.f_c_alarm").unbind("click").bind("click",cancelClockAtLeft);
			jQ("#my_event_zone div.me_box div.me_item a.f_alarm").unbind("click").bind("click",addClockAtLeft);
			jQ("#my_event_zone div.me_box div.me_item span.isvip").unbind("click").bind("click",setImportAtLeft);
		}
	});
}

function setImportAtLeft(event){
	var curObj=jQ(event.currentTarget);
	var eventid=eval(curObj.parent().prevAll("input.eventid").val());
	var ss=jQ("div.clipevent-"+eventid+" div.isvip span.isvip");
	if(curObj.hasClass("c_import")){
		
		ss.removeClass("c_import").addClass("import");
		ss.attr("title","标记为重要");
		jQ("div.clipevent-"+eventid+" input.isvip").val(0);
		setImport(false,eventid);
	}else if(curObj.hasClass("import")){
		
		ss.removeClass("import").addClass("c_import");
		ss.attr("title","标记为不重要");
		jQ("div.clipevent-"+eventid+" input.isvip").val(1);
		setImport(true,eventid);
	}
	serializeClipEventLeftToCenter(eventid);
}

function addClockAtLeft(event){
	var eventid=jQ(event.currentTarget).parent().prevAll("input.eventid").val();
	var showclock=jQ(event.currentTarget).parent().prevAll("div.show_clock");
	var setclock=jQ(event.currentTarget).parent().prevAll("div.set_clock");
//	var iconObj=jQ(event.currentTarget);
	if(showclock.css("display")=="none"){
		setclock.hide();
		showclock.show();
		return;
	}
	showclock.hide();
	setclock.show();
	setclock.find("input:checkbox").attr("checked","true");
	setclock.find("input:text").val("").datepicker( "destroy" );
	setclock.find("select.alert_hour").val(0);
	setclock.find("select.alert_min").val(0);
	setclock.find("input:text").datepicker({dateFormat: 'yy-mm-dd',  
		beforeShow: function(i,e){  
		var z = jQuery(i).closest(".ui-dialog").css("z-index") + 4;  
		e.dpDiv.css('z-index', z);  
	}});
	
	
	setclock.find("button").unbind("click").bind("click",function(){
		
		var isChecked=eval(jQ(this).prevAll("input:checkbox").attr("checked"));
		var errzone=jQ(this).parent().nextAll("div.set_clock_info");
		if(isChecked){
			var alertdateval=jQ(this).prevAll("input:text").val();
			if(alertdateval==null||alertdateval.length<=0){
				errzone.empty();
				errzone.append("请选择提醒的时间。");
				errzone.show();
				return;
			}else{
				errzone.empty();
			}
			
			var alertdate=jQ(this).prevAll("input:text").datepicker( "getDate" );
			var alerthour=eval(jQ(this).prevAll("select.alert_hour").val());
			var alertmin=eval(jQ(this).prevAll("select.alert_min").val());
			alertdate.setHours(alerthour);
			alertdate.setMinutes(alertmin);
			var alertlong=alertdate.getTime();
			var nowdate=new Date();
			if(alertlong<nowdate){
				errzone.empty();
				errzone.append("提醒的时间应该是将来的时间。");
				errzone.show();
				return;
			}else{
				errzone.empty();
			}
			var btnObj=jQ(this);
			jQ.ajax({
				type: "POST",
				url:"eventAjax!addEventClock.action",
				data:{
					eventid:eventid,
					alerttime:alertlong
				},
			success:function(data){
				if(data!=null){
					var dataObj=eval("("+data+")");//转换为json对象
					if(dataObj['result']){
						
						setclock.hide();
						showclock.show();
						btnObj.unbind("click");
						jQ("div.clipevent-"+eventid+" input.clocktime").val(alertlong);
						var ss=jQ("div.clipevent-"+eventid+" div.show_clock span.clockval");
						ss.addClass("alarm").empty().append(formateDetailTime(alertlong));
						var ss2=jQ("div.clipevent-"+eventid+" div.opt_item a.alarmicon");
						ss2.removeClass("f_alarm").addClass("f_c_alarm").attr("title","取消提醒");
						ss2.unbind("click").bind("click",cancelClockAtLeft);
						serializeClipEventLeftToCenter(eventid);
					}else{
					}
				}
			}
			});
		}else{
			errzone.empty().append("请打钩“设置提醒”选项");
			return;
		}
	});
}

function cancelClockAtLeft(event){
	var eventid=jQ(event.currentTarget).parent().prevAll("input.eventid").val();
	var setclock=jQ(event.currentTarget).parent().prevAll("div.set_clock");
	var showclock=jQ(event.currentTarget).parent().prevAll("div.show_clock");
	var iconObj=jQ(event.currentTarget);
	jQ.ajax({
		type: "POST",
		url:"eventAjax!cancelClock.action",
		data:{
			eventid:eventid
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj['result']){
					setclock.hide();
					showclock.show();
					jQ("div.clipevent-"+eventid+" input.clocktime").val(0);
					var ss=jQ("div.clipevent-"+eventid+" div.show_clock span.clockval");
					ss.removeClass("alarm").empty().append("<i>暂无</i>");
					var ss2=jQ("div.clipevent-"+eventid+" div.opt_item a.alarmicon");
					ss2.removeClass("f_c_alarm").addClass("f_alarm").attr("title","设置提醒");
					ss2.unbind("click").bind("click",addClockAtLeft);
					serializeClipEventLeftToCenter(eventid);
				}else{
					
				}
			}
		}
	});
}

function setImport(isImport,eventid){
	jQ.ajax({
		type: "POST",
		url:"eventAjax!setEventImport.action",
		data:{
			isImport:Number(isImport),
			eventid:eval(eventid)
		},
		success:function(data){
		}
	});
}

function deleteClipEvent(obj){
	var info="";
	var title="";
	if(jQ(obj).hasClass("leave")){
		info="您确定退出档期么？";
		title="退出档期";
	}else if(jQ(obj).hasClass("del")){
		info="您确定取消档期么？";
		title="取消档期";
	}
	var eventid=jQ("#td_box_eventid").val();
	jQ("#viewopt_eventid").val(eventid);
	var opt=jQ("#viewopt");
	opt.bind("deleteEvent",deleteEvent);
	opt.data("function","deleteEvent")
	jQ("#viewopt_p").empty().append(info);
	jQ("#viewopt").dialog( "option", "title",title );
	jQ("#viewopt").dialog("open");
}

function detailClipEvent(obj){
	var eventid=jQ("#td_box_eventid").val();
	window.location.href=jQ("#ctxVal").val()+"/myclip/clip_detail.html?eventid="+eventid;
}

function deleteEvent(){
	var eventid=jQ("#viewopt_eventid").val(); 
	jQ.ajax({
		type: "POST",
		url:"eventAjax!deleteEvent.action",
		data:{
			eventid:eval(eventid)
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj['result']){
					jQ("#viewopt").dialog("close");
					////////////////////////////
					afterDelForHtml(eventid);
					////////////////////////////
					if(jQ("#crtclip").nextAll().length==0&&jQ("#joinclip tr").length==0)
						noeventInCenter();
					serializeClipEventCenterToLeft(eventid);
				}else{
					jQ("#viewopt_p").empty().append(dataObj['msg']);
					jQ("#viewopt").dialog("close");
				}
			}
		}
	});
}

function afterDelForHtml(eventid){
	var startday=eval(jQ("#clipevent-"+eventid).attr("day"));
	var length=eval(jQ("#clipevent-"+eventid).attr("colspan"));
	var html="";
	for(var i=0;i<length;i++){
		html+="<td class='invite_event noevent' day="+(startday+i)+" title='双击立即添加档期'><div class='noevent'></div></td>";
	}
	jQ("#clipevent-"+eventid).after(html);
	var tr=jQ("#clipevent-"+eventid).parent();
	jQ("#clipevent-"+eventid).remove();
	if(tr.find("td.noevent").length==tr.find("td").length){
		tr.remove();
	}
	jQ("td.noevent").unbind("dblclick").bind("dblclick",noneeventdblclick);
}

function deleteEventAtLeft(){
	var eventid=jQ("#viewopt_eventid").val(); 
	jQ.ajax({
		type: "POST",
		url:"eventAjax!deleteEvent.action",
		data:{
			eventid:eval(eventid)
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj['result']){
					jQ("#viewopt").dialog("close");
					jQ("div.clipevent-"+eventid).remove();
					noeventInLeft();
					serializeClipEventLeftToCenter(eventid);
				}else{
					jQ("#viewopt_p").empty().append(dataObj['msg']);
					jQ("#viewopt").dialog("close");
				}
			}
		}
	});
}

function getWeekEventsByToday(){
	jQ.ajax({
		type: "POST",
		url:"weekAjax!getThisWeek.action",
		success:function(data){
			var jsonobj=eval("("+data+")");
			jQ("#weekinfoyear").val(jsonobj.year);
			jQ("#weekinfoweek").val(jsonobj.numweek);
			jQ("#mouth_fun_weekview_year").val(jsonobj.year);
			jQ("#weeks td").removeClass();
			jQ("#week"+jsonobj.dayofweek).addClass("today");
			for(var i=1;i<=7;i++){
				var str=jsonobj["day"+i];
				var list=str.split("_");
				var obj=jQ("#week"+i).find("p");
				obj.empty().append(list[1]+"月"+list[2]+"日");
				obj.attr("year",eval(list[0]));
				obj.attr("month",eval(list[1]));
				obj.attr("day",eval(list[2]));
			}
			initWeekOption(jsonobj.numweek,jsonobj.maxweek);
			getEventsByWeek(jsonobj.year,jsonobj.numweek);
		}
	});
}

function initWeekOption(numweek,maxweek){
	var html="";
	for(var i=1;i<=maxweek;i++){
		if(i==numweek)
			html+="<option value='"+i+"' selected='selected'>"+i+"</option>";
		else
			html+="<option value='"+i+"'>"+i+"</option>";
	}
	jQ("#mouth_fun_weekview_week").empty().append(html);
}

function getEventsByWeek(year,numweek){
	jQ.ajax({
		type: "POST",
		url:"weekAjax!getEventsByWeek.action",
		data:{
			year:eval(year),
			numweek:eval(numweek)
		},
		success:function(data){
			orgEventsToWeekViewData(data);
		}
	});
}

function noeventInCenter(){
	var html="";
	html+="<tr>";
	for(var i=1;i<=7;i++){
		html+="<td class='invite_event noevent' day="+i+" title='双击立即添加档期'><div class='noevent'></div></td>";
	}
	html+="</tr>";
	jQ("#crtclip").nextAll().remove();
	jQ("#crtclip").after(html);
	jQ("td.noevent").unbind("dblclick").bind("dblclick",noneeventdblclick);
	jQ("#joinclip").empty();
}

function noneeventdblclick(event){
	var weekday=eval(jQ(event.currentTarget).attr("day"));
	var obj=jQ("#week"+weekday).find("p");
	var year=obj.attr("year");
	var month=obj.attr("month");
	var day=obj.attr("day");
	window.location.href=jQ("#ctxVal").val()+"/myclip/add_clip.html?year="+year+"&month="+month+"&day="+day;
}

function noeventInvitedClips(){
	var html="";
	if(jQ("#last_clip_zone div.me_list").length==0){
		html="<div class='me_list'><span class=title'><i>暂无邀请</i></span></div>";
		jQ("#last_clip_zone").empty().append(html);
		jQ("#new b.msgcount24").hide();
	}else{
		jQ("#new b.msgcount24").show().empty().append(jQ("#last_clip_zone div.me_list").length);
	}
	if(jQ("#urgent_clip_zone div.me_list").length==0){
		html="<div class='me_list'><span class=title'><i>暂无邀请</i></span></div>";
		jQ("#urgent_clip_zone").empty().append(html);
		jQ("#urgent b.msgcountj").hide();
	}else{
		jQ("#urgent b.msgcountj").show().empty().append(jQ("#urgent_clip_zone div.me_list").length);
	}
}

function noeventInLeft(){
	var tmp="";
	if(jQ("#my_event_today div").length==0){
		tmp="<div class='me_list noevent'><i>暂无</i></div>";
		jQ("#my_event_today").append(tmp);
	}
	if(jQ("#my_event_tommorrow div").length==0){
		tmp="<div class='me_list noevent'><i>暂无</i></div>";
		jQ("#my_event_tommorrow").append(tmp);
	}
}

function orgEventsToWeekViewData(data){
	var htmlshare="";
	var htmljoin="";
	if(jQ(data).find("EventForView").length==0){
		noeventInCenter();
		return;
	}
	var sharearray=new Array();
	var joinarray=new Array();
	jQ(data).find("EventForView").each(function(){
		var reliedclip=eval(jQ(this).find("reliedclip").text());
		var id=eval(jQ(this).attr("id"));
		var startday=eval(jQ(this).find("startday").text());
		var endday=eval(jQ(this).find("endday").text());
		
		if(reliedclip>0){ //my_join
			var canbeadded=false;
			for(var i=0;i<joinarray.length;i++){
				var arr=joinarray[i];
				var flag=true;
				for(var j=startday-1;j<=endday-1;j++){
					if(arr[j]!=0){
						flag=false;
						break;
					}
				}
				if(flag){
					for(var j=startday-1;j<=endday-1;j++){
						arr[j]=id;
					}
					canbeadded=true;
					break;
				}
			}
			if(!canbeadded){
				var length=joinarray.length;
				joinarray[length]=new Array();
				 
				for(var j=0;j<7;j++){
					if(j>=startday-1&&j<=endday-1){
						joinarray[length][j]=id;
					}else{
						joinarray[length][j]=0;
					}
				}
			}
			
		}else{ //my_share
			var canbeadded=false;
			for(var i=0;i<sharearray.length;i++){
				var arr=sharearray[i];
				var flag=true;
				for(var j=startday-1;j<=endday-1;j++){
					if(arr[j]!=0){
						flag=false;
						break;
					}
				}
				if(flag){
					for(var j=startday-1;j<=endday-1;j++){
						arr[j]=id;
					}
					canbeadded=true;
					break;
				}
			}
			if(!canbeadded){
				var length=sharearray.length;
				sharearray[length]=new Array();
				for(var j=0;j<7;j++){
					if(j>=startday-1&&j<=endday-1){
						sharearray[length][j]=id;
					}else{
						sharearray[length][j]=0;
					}
				}
			}
		}
	});
	
	for ( var i = 0; i < joinarray.length; i++) {
		var arr=joinarray[i];
		htmljoin+= "<tr>";
		for ( var j = 0; j < 7; j++) {
			var id=arr[j];
			if(id==0){
				htmljoin+="<td class='invite_event noevent' title='双击立即添加档期' day="+j+"><div class='noevent'></div></td>";
			}else{
				var obj=jQ(data).find("EventForView[id='"+id+"']");
				var reliedclip=eval(jQ(obj).find("reliedclip").text());
				var processstatus=eval(jQ(obj).find("processstatus").text());
				var id=eval(jQ(obj).attr("id"));
				var title=jQ(obj).find("title").text();
				var eventtype=jQ(obj).find("eventtype").text();
				var starttime=eval(jQ(obj).find("starttime").text());
				var endtime=eval(jQ(obj).find("endtime").text());
				var address=jQ(obj).find("address").text();
				var content=jQ(obj).find("content").text();
				var clocktime=eval(jQ(obj).find("clocktime").text());
				var deadlinetime=eval(jQ(obj).find("deadlinetime").text());
				var isvip=eval(jQ(obj).find("isvip").text());
				var istodayortommorrow=eval(jQ(obj).find("istodayortommorrow").text());
				var publishname=jQ(obj).find("publishname").text();
				var startday=eval(jQ(obj).find("startday").text());
				var endday=eval(jQ(obj).find("endday").text());
				var eventtype=jQ(obj).find("eventtype").text();
				
				htmljoin+="<td id='clipevent-"+id+"' class='invite_event my_join hasevent' day="+startday+" colspan='"+(endday-startday+1)+"'>";
				htmljoin+="<div class='hasevent'>";
				htmljoin+="<input type='hidden' value='"+id+"' class='eventid'/>";
				htmljoin+="<input type='hidden' value='"+title+"' class='title'/>";
				htmljoin+="<input type='hidden' value='"+eventtype+"' class='eventtype'/>";
				htmljoin+="<input type='hidden' value='"+starttime+"' class='starttime'/>";
				htmljoin+="<input type='hidden' value='"+endtime+"' class='endtime'/>";
				htmljoin+="<input type='hidden' value='"+address+"' class='address'/>";
				htmljoin+="<input type='hidden' value='"+content+"' class='content'/>";
				htmljoin+="<input type='hidden' value='"+clocktime+"' class='clocktime'/>";
				htmljoin+="<input type='hidden' value='"+deadlinetime+"' class='deadlinetime'/>";
				htmljoin+="<input type='hidden' value='"+isvip+"' class='isvip filteisvip'/>";
				htmljoin+="<input type='hidden' value='"+istodayortommorrow+"' class='istodayortommorrow'/>";
				htmljoin+="<input type='hidden' value='"+processstatus+"' class='processstatus'/>";
				htmljoin+="<input type='hidden' value='"+reliedclip+"' class='reliedclip'/>";
				htmljoin+="<input type='hidden' value='"+publishname+"' class='publishname'/>";
				if(processstatus==2)
					htmljoin+="<a class='stop filteeventtype-"+eventtype+"'>"+htmlData(title)+"</a></div></td>";
				else
					htmljoin+="<a class='"+eventtype+" filteeventtype-"+eventtype+"'>"+htmlData(title)+"</a></div></td>";
				j=endday-1;
			}
		}
		htmljoin+= "</tr>";
	}
	for ( var i = 0; i < sharearray.length; i++) {
		var arr=sharearray[i];
		htmlshare+= "<tr>";
		for ( var j = 0; j < 7; j++) {
			var id=arr[j];
			if(id==0){
				htmlshare+="<td class='invite_event noevent' title='双击立即添加档期' day="+j+"><div class='noevent'></div></td>";
			}else{
				var obj=jQ(data).find("EventForView[id='"+id+"']");
				var reliedclip=eval(jQ(obj).find("reliedclip").text());
				var processstatus=eval(jQ(obj).find("processstatus").text());
				var id=eval(jQ(obj).attr("id"));
				var title=jQ(obj).find("title").text();
				var eventtype=jQ(obj).find("eventtype").text();
				var starttime=eval(jQ(obj).find("starttime").text());
				var endtime=eval(jQ(obj).find("endtime").text());
				var address=jQ(obj).find("address").text();
				var content=jQ(obj).find("content").text();
				var clocktime=eval(jQ(obj).find("clocktime").text());
				var deadlinetime=eval(jQ(obj).find("deadlinetime").text());
				var isvip=eval(jQ(obj).find("isvip").text());
				var istodayortommorrow=eval(jQ(obj).find("istodayortommorrow").text());
				var publishname=jQ(obj).find("publishname").text();
				var startday=eval(jQ(obj).find("startday").text());
				var endday=eval(jQ(obj).find("endday").text());
				var eventtype=jQ(obj).find("eventtype").text();
				
				htmlshare+="<td id='clipevent-"+id+"' class='invite_event my_share hasevent' day="+startday+" colspan='"+(endday-startday+1)+"'>";
				htmlshare+="<div class='hasevent'>";
				htmlshare+="<input type='hidden' value='"+id+"' class='eventid'/>";
				htmlshare+="<input type='hidden' value='"+title+"' class='title'/>";
				htmlshare+="<input type='hidden' value='"+eventtype+"' class='eventtype'/>";
				htmlshare+="<input type='hidden' value='"+starttime+"' class='starttime'/>";
				htmlshare+="<input type='hidden' value='"+endtime+"' class='endtime'/>";
				htmlshare+="<input type='hidden' value='"+address+"' class='address'/>";
				htmlshare+="<input type='hidden' value='"+content+"' class='content'/>";
				htmlshare+="<input type='hidden' value='"+clocktime+"' class='clocktime'/>";
				htmlshare+="<input type='hidden' value='"+deadlinetime+"' class='deadlinetime'/>";
				htmlshare+="<input type='hidden' value='"+isvip+"' class='isvip filteisvip'/>";
				htmlshare+="<input type='hidden' value='"+istodayortommorrow+"' class='istodayortommorrow'/>";
				htmlshare+="<input type='hidden' value='"+processstatus+"' class='processstatus'/>";
				htmlshare+="<input type='hidden' value='"+reliedclip+"' class='reliedclip'/>";
				htmlshare+="<input type='hidden' value='"+publishname+"' class='publishname'/>";
				if(processstatus==2)
					htmlshare+="<a class='stop filteeventtype-"+eventtype+"'>"+htmlData(title)+"</a></div></td>";
				else
					htmlshare+="<a class='"+eventtype+" filteeventtype-"+eventtype+"'>"+htmlData(title)+"</a></div></td>";
				j=endday-1;
			}
		}
		htmlshare+= "</tr>";
	}
	jQ("#crtclip").nextAll().remove();
	jQ("#crtclip").after(htmlshare);
	jQ("#joinclip").empty().append(htmljoin);
	effectEventDetail();
}
var mytimer = null;

function effectEventDetail(){
	jQ("td.noevent").unbind("dblclick").bind("dblclick",noneeventdblclick);
	jQ("td.hasevent").unbind("mouseover").bind("mouseover",function(){
		jQ(this).find("div").css({backgroundPosition: "0px -32px"});
		mytimer = window.setTimeout("myfunc('"+jQ(this).attr("id")+"')", 1000);          
	});
	jQ("td.hasevent").unbind("mouseout").bind("mouseout",function(){
		clearTimeout(mytimer);
		mytimer = -1;
		jQ(this).find("div").css({backgroundPosition: "0px 0px"});

	});
}

function myfunc(id){
	 if (mytimer == -1) return;  
     clearTimeout(mytimer);  
     mytimer = null;  
     var jQid="#"+id;
     if(jQ(jQid).hasClass("filter"))
			return;
		if(!jQ(jQid).hasClass("hasevent")){
			jQ("div.td_box").hide();
		}else{
			var text = jQ(jQid).text();
			var box = jQ(jQid).offset();
			var color = jQ(jQid).find("div").css("background-color");			
			var b_iw = jQ("table.invite_week").offset();
			var w_iw = jQ("table.invite_week").width();
			var bg_position = b_iw.left + w_iw;
			var box_position = box.left + jQ("div.td_box").width();
			if(box_position>bg_position){
				jQ("div.td_box").css({"top":box.top,"left":bg_position - jQ("div.td_box").width(),"min-width":jQ(jQid).width(),"background-color":color}); 				
			}
			else{
				jQ("div.td_box").css({"top":box.top,"left":box.left,"min-width":jQ(jQid).width(),"background-color":color}); 
			}
			addDetailContent(jQ(jQid));
			jQ("div.td_box").show("slow");
		}
}

function addDetailContent(trObj){
	var eventid=jQ(trObj).find("input.eventid").val();
	var title=jQ(trObj).find("input.title").val();
	var eventtype=jQ(trObj).find("input.eventtype").val();
	var starttime=jQ(trObj).find("input.starttime").val();
	var endtime=jQ(trObj).find("input.endtime").val();
	var address=jQ(trObj).find("input.address").val();
	var content=jQ(trObj).find("input.content").val();
	var clocktime=eval(jQ(trObj).find("input.clocktime").val());
	var deadlinetime=eval(jQ(trObj).find("input.deadlinetime").val());
	var isvip=eval(jQ(trObj).find("input.isvip").val());
	var reliedclip=eval(jQ(trObj).find("input.reliedclip").val());
	var processstatus=eval(jQ(trObj).find("input.processstatus").val());
	var publishname=jQ(trObj).find("input.publishname").val();
	jQ("#td_box_eventid").val(eventid);
	jQ("#td_box_eventtype").empty().append(getTypeName(eventtype));
	jQ("#td_box_eventtype").prev("span.event").removeClass().addClass("event "+eventtype);
	jQ("#td_box_cliptime").empty().append("<b>"+formateDetailTime(starttime)+"</b><b>至</b><b>"+formateDetailTime(endtime)+"</b>");
	jQ("#td_box_title").empty().append(htmlData(title));
	jQ("#td_box_publishname").empty().append(publishname);
	jQ("#td_box_address").empty().append(htmlData(address));
	jQ("#td_box_content").empty().append(htmlData(content));
	if(clocktime>0){
		jQ("#td_box_clocktime").empty().append(formateDetailTime(clocktime));
		jQ("#td_box_alert_icon").removeClass().addClass("c_alarm").attr("title","取消提醒");
		jQ("#td_box_alert_icon").unbind("click").bind("click",{eventid:eventid,trObj:trObj},cancelClock);
	}else{
		jQ("#td_box_clocktime").empty().append("<i>暂无</i>");
		jQ("#td_box_alert_icon").removeClass().addClass("alarm").attr("title","设置提醒");
		jQ("#td_box_alert_icon").unbind("click").bind("click",{eventid:eventid,trObj:trObj},addClock);
	}
	jQ("#td_box_deadlinetime").empty();
	if(deadlinetime>0)
		jQ("#td_box_deadlinetime").append("<b>"+formateDetailTime(deadlinetime)+"</b>");
	else{
		jQ("#td_box_deadlinetime").append("<b><i>暂无</i></b>");
	}
	if(processstatus==0){
		jQ("#td_box_processstatus").empty().append("<b class=\"edt_ing\">进行中</b>");
	}else if(processstatus==1){
		jQ("#td_box_processstatus").empty().append("<b class=\"edt_over\">已结束</b>");
	}else if(processstatus==2){
		jQ("#td_box_processstatus").empty().append("<b class=\"edt_stop\">已停止</b>");
	}
	if(isvip==1)
		jQ("#td_box_isvip").addClass("c_import").attr("title","标记为不重要");
	
	else{
		jQ("#td_box_isvip").removeClass("c_import").attr("title","标记为重要");
	}
	if(reliedclip>0){
		jQ("#td_box_deve_icon").removeClass().addClass("leave").attr("title","退出档期");
	}else{
		jQ("#td_box_deve_icon").removeClass().addClass("del").attr("title","取消档期");
	}
	
}

function cancelClock(event){
	var eventid=event.data.eventid;
	var trObj=event.data.trObj;
	jQ.ajax({
		type: "POST",
		url:"eventAjax!cancelClock.action",
		data:{
			eventid:eventid
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj['result']){
					jQ(trObj).find("input.clocktime").val("");
					jQ("#td_box_clocktime").empty().append("<i>暂无</i>");
					jQ("#td_box_alert_icon").removeClass().addClass("alarm").attr("title","设置提醒");
					jQ("#td_box_alert_icon").unbind("click").bind("click",{eventid:eventid,trObj:trObj},addClock);
					serializeClipEventCenterToLeft(eventid);
					
				}else{
				}
			}
		}
	});
}

function addClock(event){
	var eventid=event.data.eventid;
	var trObj=event.data.trObj;
	if(jQ("#td_box_showclock").css("display")=="none"){
		jQ("#td_box_setclock").hide();
		jQ("#td_box_showclock").show();
		return;
	}
	jQ("#td_box_showclock").hide();
	jQ("#td_box_setclock").show();
	
	jQ("#td_box_setclock input:checkbox").attr("checked","true");
	jQ("#td_box_setclock input:text").datepicker( "destroy" );
	jQ("#td_box_setclock input:text").datepicker({dateFormat: 'yy-mm-dd',  
		beforeShow: function(i,e){  
		var z = jQuery(i).closest(".ui-dialog").css("z-index") + 4;  
		e.dpDiv.css('z-index', z);  
	}});
	
	
	jQ("#td_box_setclock button").unbind("click").bind("click",function(){
		var isChecked=eval(jQ("#td_box_setclock input:checkbox").attr("checked"));
		var errzone=jQ("#td_box_setclock_info");
		if(isChecked){
			var alertdateval=jQ("#td_box_setclock input:text").val();
			if(alertdateval==null||alertdateval.length<=0){
				errzone.empty();
				errzone.append("请选择提醒的时间。");
				errzone.show();
				return;
			}else{
				errzone.empty();
			}
			
			var alertdate=jQ("#td_box_setclock input:text").datepicker( "getDate" );
			var alerthour=eval(jQ("#td_box_setclock select.alert_hour").val());
			var alertmin=eval(jQ("#td_box_setclock select.alert_min").val());
			alertdate.setHours(alerthour);
			alertdate.setMinutes(alertmin);
			var alertlong=alertdate.getTime();
			var nowdate=new Date();
			if(alertlong<nowdate){
				errzone.empty();
				errzone.append("提醒的时间应该是将来的时间。");
				errzone.show();
				return;
			}else{
				errzone.empty();
			}
			
			jQ.ajax({
				type: "POST",
				url:"eventAjax!addEventClock.action",
				data:{
					eventid:eventid,
					alerttime:alertlong
				},
			success:function(data){
					
				if(data!=null){
					var dataObj=eval("("+data+")");//转换为json对象
					if(dataObj['result']){
						jQ("#td_box_setclock").hide();
						jQ("#td_box_showclock").show();
						jQ("#td_box_setclock button").unbind("click");
						
						jQ(trObj).find("input.clocktime").val(alertlong);
						jQ("#td_box_clocktime").empty().append(formateDetailTime(alertdate));
						
						jQ("#td_box_alert_icon").removeClass().addClass("c_alarm").attr("title","取消提醒");
						jQ("#td_box_alert_icon").unbind("click").bind("click",{eventid:eventid,trObj:trObj},cancelClock);
						serializeClipEventCenterToLeft(eventid);
					}else{
//						jQ("#viewopt_p").empty().append(dataObj['msg']);
//						jQ("#viewopt").dialog("close");
					}
				}
			}
			});
		}else{
			errzone.empty().append("请打钩“设置提醒”选项");
			return;
		}
	});
}

function serializeClipEventCenterToLeft(eventid){
	var trObj=jQ("#clipevent-"+eventid);
	if(trObj.length==0){
		jQ("div.clipevent-"+eventid).remove();
		noeventInLeft();
		return;
	}
	var clocktime=eval(jQ(trObj).find("input.clocktime").val());
	var isvip=eval(jQ(trObj).find("input.isvip").val());
	var leftObjs=jQ("div.clipevent-"+eventid);
	leftObjs.find("input.clocktime").val(clocktime);
	leftObjs.find("input.isvip").val(isvip);
	if(isvip)
		leftObjs.find("div span.isvip").removeClass("import").addClass("c_import").attr("title","标记为不重要");
	else
		leftObjs.find("div span.isvip").removeClass("c_import").addClass("import").attr("title","标记为重要");
	var alarmobj=leftObjs.find("div.opt_item a.alarmicon");
	if(clocktime>0){
		leftObjs.find("div.show_clock span.clockval").addClass("alarm").empty().append(formateDetailTime(clocktime));
		alarmobj.removeClass("f_alarm");
		if(!alarmobj.hasClass("f_c_alarm"))
			alarmobj.addClass("f_c_alarm");
		alarmobj.attr("title","取消提醒");
		alarmobj.unbind("click").bind("click",cancelClockAtLeft);
	}else{
		leftObjs.find("div.show_clock span.clockval").removeClass("alarm").empty().append("<i>暂无</i>");
		alarmobj.removeClass("f_c_alarm");
		if(!alarmobj.hasClass("f_alarm"))
			alarmobj.addClass("f_alarm");
		alarmobj.attr("title","设置提醒");
		alarmobj.unbind("click").bind("click",addClockAtLeft);
	}
	
}


function serializeClipEventLeftToCenter(eventid){
	var leftObjs=jQ("div.clipevent-"+eventid);
	if(leftObjs.length==0){
		afterDelForHtml(eventid);
		if(jQ("#crtclip").nextAll().length==0&&jQ("#joinclip tr").length==0){
			noeventInCenter();
		}
		return;
	}
	var clocktime=eval(leftObjs.find("input.clocktime").val());
	var isvip=eval(leftObjs.find("input.isvip").val());
	var trObjs=jQ("#clipevent-"+eventid);
	trObjs.find("input.clocktime").val(clocktime);
	trObjs.find("input.isvip").val(isvip);
}

function onSelectOpt(flag){
	jQ("div.td_box").data("flag",flag);
}

function changeWeekView(){
	var year=eval(jQ("#mouth_fun_weekview_year").val());
	var week=eval(jQ("#mouth_fun_weekview_week").val());
	jQ.ajax({
		type: "POST",
		url:"weekAjax!getUserDefinedWeek.action",
		data:{
			year:year,
			numweek:week
		},
		success:function(data){
			var jsonobj=eval("("+data+")");
			//jQ("#weekviewdateinfo").empty().append("<input type='hidden' id='weekinfoyear' value='"+jsonobj.year+"'/><input type='hidden' id='weekinfoweek' value='"+jsonobj.numweek+"'/><span>"+jsonobj.year+"</span>年，第<span>"+jsonobj.numweek+"</span>周");
			jQ("#mouth_fun_weekview_year").val(jsonobj.year);
			jQ("#weeks td").removeClass();
			var dayofweek=eval(jsonobj.dayofweek);
			if(dayofweek>0&&dayofweek<=7)
				jQ("#week"+dayofweek).addClass("today");
			for(var i=1;i<=7;i++){
				var str=jsonobj["day"+i];
				var list=str.split("_");
				var obj=jQ("#week"+i).find("p");
				obj.empty().append(list[1]+"月"+list[2]+"日");
				obj.attr("year",eval(list[0]));
				obj.attr("month",eval(list[1]));
				obj.attr("day",eval(list[2]));
			}
			initWeekOption(jsonobj.numweek,jsonobj.maxweek);
			getEventsByWeek(jsonobj.year,jsonobj.numweek);
		}
	});
}

function prevYearClick(){
	var year=eval(jQ("#mouth_fun_weekview_year").val());
	var week=eval(jQ("#mouth_fun_weekview_week").val());
	jQ.ajax({
		type: "POST",
		url:"weekAjax!getPrevYear.action",
		data:{
			year:year,
			numweek:week
		},
		success:function(data){
			var jsonobj=eval("("+data+")");
			jQ("#mouth_fun_weekview_year").val(jsonobj.year);
			jQ("#weeks td").removeClass();
			var dayofweek=eval(jsonobj.dayofweek);
			if(dayofweek>0&&dayofweek<=7)
				jQ("#week"+dayofweek).addClass("today");
			for(var i=1;i<=7;i++){
				var str=jsonobj["day"+i];
				var list=str.split("_");
				var obj=jQ("#week"+i).find("p");
				obj.empty().append(list[1]+"月"+list[2]+"日");
				obj.attr("year",eval(list[0]));
				obj.attr("month",eval(list[1]));
				obj.attr("day",eval(list[2]));
			}
			initWeekOption(jsonobj.numweek,jsonobj.maxweek);
			getEventsByWeek(jsonobj.year,jsonobj.numweek);
		}
	});
}
function prevWeekClick(){
	var year=eval(jQ("#mouth_fun_weekview_year").val());
	var week=eval(jQ("#mouth_fun_weekview_week").val());
	jQ.ajax({
		type: "POST",
		url:"weekAjax!getPrevWeek.action",
		data:{
			year:year,
			numweek:week
		},
		success:function(data){
			var jsonobj=eval("("+data+")");
			jQ("#mouth_fun_weekview_year").val(jsonobj.year);
			jQ("#weeks td").removeClass();
			var dayofweek=eval(jsonobj.dayofweek);
			if(dayofweek>0&&dayofweek<=7)
				jQ("#week"+dayofweek).addClass("today");
			for(var i=1;i<=7;i++){
				var str=jsonobj["day"+i];
				var list=str.split("_");
				var obj=jQ("#week"+i).find("p");
				obj.empty().append(list[1]+"月"+list[2]+"日");
				obj.attr("year",eval(list[0]));
				obj.attr("month",eval(list[1]));
				obj.attr("day",eval(list[2]));
			}
			initWeekOption(jsonobj.numweek,jsonobj.maxweek);
			getEventsByWeek(jsonobj.year,jsonobj.numweek);
		}
	});
}
function nextYearClick(){
	var year=eval(jQ("#mouth_fun_weekview_year").val());
	var week=eval(jQ("#mouth_fun_weekview_week").val());
	jQ.ajax({
		type: "POST",
		url:"weekAjax!getNextYear.action",
		data:{
			year:year,
			numweek:week
		},
		success:function(data){
			var jsonobj=eval("("+data+")");
			jQ("#mouth_fun_weekview_year").val(jsonobj.year);
			jQ("#weeks td").removeClass();
			var dayofweek=eval(jsonobj.dayofweek);
			if(dayofweek>0&&dayofweek<=7)
				jQ("#week"+dayofweek).addClass("today");
			for(var i=1;i<=7;i++){
				var str=jsonobj["day"+i];
				var list=str.split("_");
				var obj=jQ("#week"+i).find("p");
				obj.empty().append(list[1]+"月"+list[2]+"日");
				obj.attr("year",eval(list[0]));
				obj.attr("month",eval(list[1]));
				obj.attr("day",eval(list[2]));
			}
			initWeekOption(jsonobj.numweek,jsonobj.maxweek);
			getEventsByWeek(jsonobj.year,jsonobj.numweek);
		}
	});
}
function nextWeekClick(){
	var year=eval(jQ("#mouth_fun_weekview_year").val());
	var week=eval(jQ("#mouth_fun_weekview_week").val());
	jQ.ajax({
		type: "POST",
		url:"weekAjax!getNextWeek.action",
		data:{
			year:year,
			numweek:week
		},
		success:function(data){
			var jsonobj=eval("("+data+")");
			jQ("#mouth_fun_weekview_year").val(jsonobj.year);
			jQ("#weeks td").removeClass();
			var dayofweek=eval(jsonobj.dayofweek);
			if(dayofweek>0&&dayofweek<=7)
				jQ("#week"+dayofweek).addClass("today");
			for(var i=1;i<=7;i++){
				var str=jsonobj["day"+i];
				var list=str.split("_");
				var obj=jQ("#week"+i).find("p");
				obj.empty().append(list[1]+"月"+list[2]+"日");
				obj.attr("year",eval(list[0]));
				obj.attr("month",eval(list[1]));
				obj.attr("day",eval(list[2]));
			}
			initWeekOption(jsonobj.numweek,jsonobj.maxweek);
			getEventsByWeek(jsonobj.year,jsonobj.numweek);
		}
	});
}

function filterEvent(obj,typename){
	var flag=eval(jQ(obj).attr("checked"));
	var tdobj;
	if(typename=='other'){
		tdobj=jQ("a.filteeventtype-other").parent().parent();
		jQ("div.filter-other input:checkbox").attr("checked",flag);
	}else if(typename=='work'){
		tdobj=jQ("a.filteeventtype-work").parent().parent();
		jQ("div.filter-work input:checkbox").attr("checked",flag);
	}else if(typename=='socal'){
		tdobj=jQ("a.filteeventtype-socal").parent().parent();
		jQ("div.filter-socal input:checkbox").attr("checked",flag);
	}else if(typename=='sect'){
		tdobj=jQ("a.filteeventtype-sect").parent().parent();
		jQ("div.filter-sect input:checkbox").attr("checked",flag);
	}else if(typename=='import'){
		jQ("div.filter-import input:checkbox").attr("checked",flag);
		tdobj=jQ("input.filteisvip[value='0']").parent().parent();
	}else if(typename=='c_import'){
		jQ("div.filter-c_import input:checkbox").attr("checked",flag);
		tdobj=jQ("input.filteisvip[value='1']").parent().parent();
	}
	if(flag){
		tdobj.removeClass("filter");
		tdobj.parent().each(function(){
			if(jQ(this).find("td").length>jQ(this).find("td.filter").length+jQ(this).find("td.noevent").length){
				jQ(this).show();
			}
		});
	}else{
		tdobj.addClass("filter");
		tdobj.parent().each(function(){
			if(jQ(this).find("td").length==jQ(this).find("td.filter").length+jQ(this).find("td.noevent").length){
				jQ(this).hide();
			}
		});
	}
}


//右边栏特效
function view_fun(obj){
//	if(jQ(obj).hasClass("onit")){
//		jQ("div.view_con").animate({"width":"0px"},"slow",function(){
//			jQ("div.view_con").css("border-width","0");
//			jQ(obj).removeClass("onit");
//		});
//		jQ("div.view_fun").animate({"width":"50px"},"slow");
//		jQ("div.vf_invite").children("div").hide();
//	}
//	else{
		var effectcolor=jQ(obj).attr("borderc");
		jQ("div.view_con").css("border","1px solid #"+effectcolor);
//		if(!jQ("div.vt_oc a").hasClass("onit")){
//			jQ("div.view_fun").animate({"width":"305px"},"slow",function(){
//				jQ("div.view_con").animate({"width":"257px","border-width":"1px"},"slow");
//			});
//		}
		var effectid=jQ(obj).attr("effectzone");
		jQ("div.vf_invite").children("div").hide();
		jQ("#"+effectid).show();
		jQ("#vt_oc_optzone a").removeClass("onit");
		jQ(obj).addClass("onit");
//	}
}

function formateDetailTime(daytime){
	var temp=new Date();
	temp.setTime(daytime);
	return temp.pattern("yyyy-MM-dd HH:mm");
}

function getTypeName(eng){
	if(eng=='other'){
		return "其他";
	}else if(eng=='work'){
		return "工作";
	}else if(eng=='socal'){
		return "社交";
	}else if(eng=='sect'){
		return "私人";
	}
}

function initTimeSelect(){
	jQ("#td_box_setclock select.time_hour").empty();
	var html="";
	for(var i=0;i<24;i++){
		if(i==0)
			html+="<option value="+i+">0"+i+"</option>";
		else if(i<10)
			html+="<option value="+i+">0"+i+"</option>";
		else
			html+="<option value="+i+">"+i+"</option>";
	}
	jQ("#td_box_setclock select.time_hour").append(html);
	html="";
	jQ("#td_box_setclock select.time_min").empty();
	for(var i=0;i<12;i++){
		var j=i*5;
		if(j==0)
			html+="<option value="+j+">0"+j+"</option>";
		else if(j<10)
			html+="<option value="+j+">0"+j+"</option>";
		else
			html+="<option value="+j+">"+j+"</option>";
	}
	jQ("#td_box_setclock select.time_min").append(html);
}


